package com.bawei.week.repair

import androidx.lifecycle.MutableLiveData
import com.bawei.lib_base.entity.RepairBean
import com.bawei.lib_base.entity.RepairBeanItem
import com.bawei.lib_base.mvvm.BaseViewModel
import com.bawei.lib_base.utils.ApiService
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject

@HiltViewModel
class RepairViewModel @Inject constructor(val apiService: ApiService) : BaseViewModel(){
    val repairSuc = MutableLiveData<RepairBean>()

    val repairAddSuc = MutableLiveData<RepairBeanItem>()

    fun getRepair(){
        httpRetrofit({apiService.getRepair()},repairSuc :: postValue)
    }

    fun getRepairSearch(repairName : String){
        httpRetrofit({apiService.getRepairSearch(repairName)},repairSuc :: postValue)
    }

    fun getRepairAdd(repairBeanItem: RepairBeanItem){
        httpRetrofit({apiService.getRepairAdd(mapToBody(repairBeanItem))},repairAddSuc :: postValue)
    }
}